package com.mgq.juc.cas;

import java.util.concurrent.atomic.AtomicInteger;

public class TestAtomic {
    public static void main(String[] args) {


        AtomicInteger atomicInteger = new AtomicInteger(0);
        //自增1
        System.out.println(atomicInteger.incrementAndGet()); //++i; 1
        System.out.println(atomicInteger.getAndIncrement()); //++i; 1
        //自增提供的值
        System.out.println(atomicInteger.get()); //2
        System.out.println(atomicInteger.getAndAdd(5));   //2
        System.out.println(atomicInteger.addAndGet(5));  //12

        //updateAndGet                                原始值     设置的值
        System.out.println(atomicInteger.updateAndGet(value -> value * 10));

    }
}
